package com.example.smart2;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.LinearLayout;

import java.util.Timer;

public class SplashActivity extends AppCompatActivity {

    private ImageView imageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        ActionBar actionBar=getSupportActionBar();
        if(actionBar!=null){
            actionBar.hide();
        }
        imageView=(ImageView) findViewById(R.id.imageView);
        AlphaAnimation animation=new AlphaAnimation(0.3f,1.0f);
        animation.setDuration(2000);
        imageView.startAnimation(animation);
        animation.setAnimationListener(new An());
    }
    private class An implements Animation.AnimationListener{
        @Override
        public void onAnimationStart(Animation animation){
            imageView.setBackgroundResource(R.drawable.slide1);
        }

        @Override
        public void onAnimationEnd(Animation animation){
            stop();
        }

        @Override
        public void onAnimationRepeat(Animation animation){

        }
    }

    private void stop(){
        startActivity(new Intent(this,MainActivity.class));
        finish();
    }

}